<?php 

$connection=mysql_connect('mysql.webio.pl', '2217_endq', 'flash2023*');
		if ($connection){
			if (!mysql_select_db('2217_endqtest', $connection)){
				echo "Can\'t choose db";
			}
		}else{
			echo "Connection error";
		}	

if(isset($_SESSION['loginen'])) {
	echo "Zalogowany jako: ".$_SESSION['login']; 
}else{
  if(isset($_POST['send'])) {
    if(mysql_num_rows(mysql_query("SELECT name, password FROM _suser WHERE name='".$_POST['login']."' and password='".$_POST['password']."' ")) > 0) {
           $_SESSION['loginen'] = true;
           $_SESSION['login'] = $_POST['login'];
           $_SESSION['password'] = $_POST['password'];
           echo "<br/><b>Zalogowano jako: ".$_SESSION['login']."</b><br/>"; 
           header('Location: '.Communicator::$location.'');
     } else { 
        echo "<br/><b>Nie ma takiego uzytkownika</b><br/>";
	 }
   }
}

?>
<br/>
	<b>Zaloguj sie</b> <br/><br/>
	<form method='POST' action='?page=login'>
	<table>
	  <tr>
	    <td style="width:150px;">Nazwa uzytkownika:</td>
	    <td><input class="formElement" type="text" value=""  name='login'/></td>
	  </tr>
	  <tr>
	    <td>Haslo:</td>
	    <td><input class="formElement" type="password" value="" name='password' /></td>
	  </tr>
	</table>
	<br/>
	<input type="submit" value="Zaloguj" name="send" />
	</form> 
	<br/>